import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;

public class Apl {
	private final static String VERTICES_FILENAME = "textFiles/Vertices3.txt";
	private final static String EDGES_FILENAME = "textFiles/Edges3.txt";
	private static PertNetwerk pertnetwerk = new PertNetwerk();

	public static void main(String args[]) {
		addVertex();
		addEdge();

		pertnetwerk.topologischSort();
		pertnetwerk.decideEarliestTime();
		pertnetwerk.decideLatestTime();

		System.out.println(pertnetwerk.toString());
	}

	public static void addVertex() {
		BufferedReader read;
		try {
			read = new BufferedReader(new FileReader(VERTICES_FILENAME));
			while (read.ready()) {
				String test = read.readLine();
				pertnetwerk.putVertex(test);
			}
		} catch (FileNotFoundException e) {
			System.out.println("Het werkt niet: File not found");
			e.printStackTrace();
		} catch (IOException e) {
			System.out.println("Het werkt niet");
			e.printStackTrace();
		}

	}

	public static void addEdge() {
		try {
			BufferedReader read = new BufferedReader(new FileReader(
					EDGES_FILENAME));
			while (read.ready()) {
				String test = read.readLine();

				String[] testen = test.split(" -> ");

				pertnetwerk.putEdge(testen[0], testen[1],
						Integer.parseInt(testen[2]));
			}
		} catch (FileNotFoundException e) {
			System.out.println("Het werkt niet: File not found");
			e.printStackTrace();
		} catch (IOException e) {
			System.out.println("Het werkt niet");
			e.printStackTrace();
		}

	}

}
